package com.ailight.smart.ai.domain.dto.deepseek;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

/**
 * @author: 朱海鹏
 * @Package: com.ailight.smart.ai.domain.dto.deepseek
 * @Project: ai-light
 * @date: 2025/3/19 11:18
 * @description :
 */
@Data
public class DpAnswerDTO implements Serializable {
    @Serial
    private static final long serialVersionUID = -1679916805630391246L;

    private String id;

    private String object;

    private Long created;

    private String model;

    private List<Choice> choices;

    private Usage usage;

    @JsonProperty("system_fingerprint")
    private String systemFingerprint;

    @Data
    public static class Choice implements Serializable {

        @Serial
        private static final long serialVersionUID = -2022458616432044396L;

        private Integer index;

        private Message message;

        private Object logprobs; // 可以是 null

        @JsonProperty("finish_reason")
        private String finishReason;
    }

    @Data
    public static class Message implements Serializable {
        @Serial
        private static final long serialVersionUID = 4407746700511181568L;

        private String role;

        private String content;

        @JsonProperty("reasoning_content")
        private String reasoningContent;
    }

    @Data
    public static class Usage implements Serializable {
        @Serial
        private static final long serialVersionUID = 7664931405008593061L;

        @JsonProperty("prompt_tokens")
        private Integer promptTokens;

        @JsonProperty("completion_tokens")
        private Integer completionTokens;

        @JsonProperty("total_tokens")
        private Integer totalTokens;

        @JsonProperty("prompt_tokens_details")
        private PromptTokensDetails promptTokensDetails;

        @JsonProperty("completion_tokens_details")
        private CompletionTokensDetails completionTokensDetails;

        @JsonProperty("prompt_cache_hit_tokens")
        private Integer promptCacheHitTokens;

        @JsonProperty("prompt_cache_miss_tokens")
        private Integer promptCacheMissTokens;
    }

    @Data
    public static class PromptTokensDetails implements Serializable {

        @Serial
        private static final long serialVersionUID = 1251073041912622993L;

        @JsonProperty("cached_tokens")
        private String cachedTokens;
    }

    @Data
    public static class CompletionTokensDetails implements Serializable {
        @Serial
        private static final long serialVersionUID = -3693222731878877960L;

        @JsonProperty("reasoning_tokens")
        private String reasoningTokens;
    }
}
